package com.yh.hljapp.modules.adatper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;

import com.yh.hljapp.R;
import com.yh.hljapp.modules.bean.View_MY_SaleBillEntry;

import butterknife.ButterKnife;
import butterknife.InjectView;
import co.lujun.androidtagview.TagContainerLayout;

public class SaleBillEntryAdapter  extends ListBaseAdapter<View_MY_SaleBillEntry> {

    static class ViewHolder {
        @InjectView(R.id.tv_product_title)
        TextView tv_product_title;
        @InjectView(R.id.tv_product_type)
        TextView tv_product_type;
        @InjectView(R.id.one_wind)
        CheckBox one_wind;
        @InjectView(R.id.tv_index)
        TextView tv_index;
        @InjectView(R.id.tv_product_count)
        TextView tv_product_count;
        @InjectView(R.id.tv_money)
        TextView tv_money;
        @InjectView(R.id.tv_item_ck_num1)
        TextView tv_item_ck_num1;
        @InjectView(R.id.tv_item_ck_num2)
        TextView tv_item_ck_num2;
        @InjectView(R.id.tv_product_ck)
        TextView tv_product_ck;
        @InjectView(R.id.tv_product_name)
        TextView tv_product_name;
        @InjectView(R.id.tagcontainerLayout_undone)
        TagContainerLayout tagcontainerLayout_undone;
        public ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }

    String type;
    public  SaleBillEntryAdapter(String type){
        this.type=type;
    }

    @Override
    protected View getRealView(final int position, View convertView, ViewGroup parent) {
        ViewHolder vh = null;
        if (convertView == null || convertView.getTag() == null) {
            convertView = getLayoutInflater(parent.getContext()).inflate(
                    R.layout.item_ck_action_line, null);
            vh = new ViewHolder(convertView);
            convertView.setTag(vh);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }

        if ("CK".equals(type)) {
            View_MY_SaleBillEntry blog = mDatas.get(position);
            vh.tv_product_title.setText(blog.getBatchNo());
            vh.one_wind.setVisibility(View.GONE);
            vh.tv_index.setText(position+"");
            vh.tv_product_type.setText(blog.getProjectName());
            vh.tv_product_count.setText(blog.getFSourceBillNo());
            vh.tv_money.setText(blog.getMenNo());
            vh.tv_product_ck.setText(blog.getLibName());
            vh.tagcontainerLayout_undone.setVisibility(View.GONE);
            vh.tv_product_name.setText(blog.getProutName());
            vh.tv_item_ck_num1.setText("发货通知单号：");
            vh.tv_item_ck_num2.setText("门编号："+blog.getFEntrySelfA0243());
        }else if ("RK".equals(type)){
            View_MY_SaleBillEntry blog = mDatas.get(position);
            vh.tv_product_title.setText(blog.getBatchNo());
            vh.one_wind.setVisibility(View.GONE);
            vh.tv_index.setText(position+"");
            vh.tv_product_title.setVisibility(View.GONE);
            vh.tv_product_type.setVisibility(View.GONE);
            vh.tagcontainerLayout_undone.setVisibility(View.GONE);
            vh.tv_product_count.setText(blog.getFSourceBillNo());
            vh.tv_money.setText(blog.getMenNo());
            vh.tv_product_ck.setText(blog.getLibName());
            vh.tv_product_name.setText(blog.getProutName());
            vh.tv_item_ck_num1.setText("派工单单号：");
            vh.tv_item_ck_num2.setText("门编号："+blog.getFEntrySelfA0243());
        }
        return convertView;
    }
}
